let Koa=require("koa");
let router=require("koa-router")();
let parser=require("koa-parser");
let app=new Koa();
app.listen(3000);
app.use(parser());
let arr=["香蕉","苹果","鸭梨"]
router.get("/doc",async ctx=>{
    ctx.body=arr;
})
router.post("/doc",async ctx=>{
    let inp=ctx.request.body.name;
    arr.push(inp);
    ctx.body=arr;
})
router.put("/doc/:id",async ctx=>{
    let id=ctx.params.id;
    let put=ctx.request.body.name;
    arr.splice(id,1,put)
    ctx.body=arr
})
router.delete("/doc/:id",async ctx=>{
    let id=ctx.params.id;
    arr.splice(id,1);
    ctx.body=arr
})
app.use(router.routes())